<template>
    <div class="con">
        <yd-tab :callback="function(label,tabkey){changeTab(label,tabkey)}">
            <yd-tab-panel label="我的信息" tabkey="0">
                <yd-cell-group>
                    <yd-cell-item v-for="item in infoItem" v-if="item.isArrow" arrow type="a"
                                  href="./cardManagement.html?pId=10&navId=56">
                        <span slot="left">{{item.title}}</span>
                        <span slot="right">{{item.text}}</span>
                    </yd-cell-item>
                    <yd-cell-item v-else>
                        <span slot="left">{{item.title}}</span>
                        <span slot="right">{{item.text}}</span>
                    </yd-cell-item>
                </yd-cell-group>
            </yd-tab-panel>
            <yd-tab-panel label="详细信息" tabkey="1">
                <div v-if="detailItem">
                    <yd-cell-item v-for="item in detailItem" v-if="item.type=='img'">
                        <span slot="left">{{item.title}}</span>
                        <span slot="right" v-if="detailItem"><img :src="item.text"></span>
                    </yd-cell-item>
                    <yd-cell-item v-else>
                        <span slot="left">{{item.title}}</span>
                        <span slot="right" v-if="detailItem">{{item.text}}</span>
                    </yd-cell-item>
                </div>
            </yd-tab-panel>
        </yd-tab>
    </div>
</template>
<script>
    import AjaxHttp from '../../js/ajaxHttp.js';
    import Tools from '../../js/tools.js';
    import Config from '../../js/config.js';
    export default{
        data: function () {
            return {
                infoItem: '',
                detailItem: '',
                mottoItem: ''
            }
        },
        created: function () {
            var _this = this;
            AjaxHttp.getHttp('fxsys/userInfo/index').then(function (response) {
                _this.infoItem = [
                    {title: '姓名', text: response.username, isArrow: false},
                    {title: '账号', text: response.userAccountID, isArrow: false},
                    {title: '邮箱', text: response.email, isArrow: false},
                    {title: '手机号', text: response.mobile, isArrow: false},
                    {title: 'MT5账号个数', text: response.mt5AccountNum, isArrow: false},
                    {title: '身份', text: response.roles, isArrow: false},
                    {title: '银行卡', text: response.bankCardNum + '张', isArrow: true}
                ];
            });
        },
        methods: {
            changeTab: function (label, tabkey) {
                console.log(label, tabkey);
                if (tabkey == 1) {
                    this.getDetailInfo();
                } else if (tabkey == 2) {
                    this.getMotto();
                }
            },
            getDetailInfo: function () {
                var _this = this;
                AjaxHttp.getHttp('fxsys/userInfo/detialUserInfo').then(function (response) {
                    //response.cardIMG1 = response.cardIMG1 ? commons.config.domain + response.cardIMG1 : '';
                    //response.cardIMG2 = response.cardIMG2 ? commons.config.domain + response.cardIMG2 : '';
                    _this.detailItem = response;
                    console.log(_this.detailItem);
                    _this.detailItem = [
                        {title: '姓名', text: response.usename},
                        {title: '性别', text: response.sex == 2 ? '女' : '男'},
                        {title: '邮箱', text: response.email},
                        {title: '手机号', text: response.mobile},
                        {title: '证件类型', text: response.identityCardType},
                        {title: '证件号码', text: response.identityCard},
                        {title: '证件图片正面', text: Config.domain + response.cardIMG1, type: 'img'},
                        {title: '证件图片反面', text: Config.domain + response.cardIMG2, type: 'img'},
                        {title: 'QQ', text: response.qqInfo},
                        {title: 'MSN', text: response.msn},
                        {title: '家庭电话', text: response.homeTel},
                        {title: '地区', text: response.province + response.cityInfo + response.contyArea},
                        {title: '邮编', text: response.postInfo},
                        {title: '地址', text: response.address1},
                        {title: '股票市场经验', text: response.stockExperience},
                        {title: '外汇市场经验', text: response.forexExperience},
                        {title: '期货市场经验', text: response.futuresExperience},
                        {title: '期权市场经验', text: response.shareOptionExperience},
                        {title: '其他', text: response.otherExperience}
                    ]
                });
            },
            getMotto: function () {
                var _this = this;
                AjaxHttp.getHttp('fxsys/userInfo/myNoteInfo').then(function (response) {
                    console.log(response);
                    _this.mottoItem = response;
                });
            }
        }
    }
</script>